<?php
	class Page_model extends CI_Model
	{
		var $table = "db_page";
		public function __construct()
		{
			parent::__construct();
		}
        function add_page($data)
        {
            $data = array(
            'heading'       => $data['heading'],
            'title'         => $data['title'],
            'description'   => $data['description'],
            'meta_keyword'  => $data['meta_keyword'],
            'meta_description'=> $data['meta_description'],
            'order_page'    => $data['order_page'],
            'active'        => $data['active'],
            'url_page'        => $data['url_page']      
            );
            $this->db->set($data);
            if($this->db->insert($this->table)) return true ; else false;
        }
        function update_page($id,$data)
        {
            $this->db->where('id_page',$id);
            $data = array(
            'heading'       => $data['heading'],
            'title'         => $data['title'],
            'description'   => $data['description'],
            'meta_keyword'  => $data['meta_keyword'],
            'meta_description'=> $data['meta_description'],
            'order_page'    => $data['order_page'],
            'active'        => $data['active'],
            'url_page'        => $data['url_page']    
            );
            $this->db->set($data);
            if($this->db->update($this->table)) return true ; else false;
        }
        function delete_page($id)
        {
            $this->db->where('id_page',$id);
            return $this->db->delete($this->table);           
        }
        function get_by_page($id)
        {
            $this->db->where('id_page',$id);
            return $this->db->get($this->table)->row();
            
        }
        function list_page()
        {
            return $this->db->get($this->table)->result();
            
        }
        function update_active($id,$data)
        {
            $this->db->where('id_page',$id);
            $data = array(
                'active' => $data['active']
            );
            $this->db->set($data);
            if($this->db->update($this->table)) return true; else return false;
        }
    }
?>    